/-app ...
/-app/boot
/-app/layout
/-app/loaded
/-app/loadedUnmanaged
/-app/loading ...
LoadFile.ts
/-app/mscorlib
/-app/tree
Application.ts
ApplicationOld.ts
earlyinit.js
format.ts
lateinit.js
/-core
/-headers
/-imports
/-io
/-managed
/-typings
/-unmanaged
pe.html
pe.ts
1
module pe.app.loading {
2
 
3
  /**
4
   * Backing file loading screen.
5
   * This class is ViewModel bound to DOM with Knockout.js.
6
   * Parametrized with an ArrayBuffer loading function (async)
7
   * and a scheduler that can yield. 
8
   */
9
  export class LoadFile {
10
 
11
    className = ko.observable('');
12
    shortText = ko.observable('');
13
    progressRatio = ko.observable(0);
14
 
15
    private static _loadWorkPart = 0.2;
16
 
17
    constructor(
18
      arrayBufferSource: (callback: AsyncCallback<ArrayBuffer>) => void,
19
      yieldScheduler: AsyncCallback.YieldCallback) {
20
 
21
      var callback: any = (error, arrayBuffer) =>
22
        this._arrayBufferComplete(error, arrayBuffer);
23
 
24
      callback.progress = (current, total, text = this.shortText()) => {
25
 
26
        this.progressRatio(LoadFile._loadWorkPart * current / total);
27
        this.shortText(text);
28
 
29
      };
30
 
31
      this.className('pe-loading-getdata');
32
      this.shortText('wait');
33
      this.progressRatio(0);
34
      arrayBufferSource(callback);
35
 
36
    }
37
 
38
    private _arrayBufferComplete(error: Error, arrayBuffer: ArrayBuffer) {
39
      if (error) {
40
        this.className('pe-loading-error');
41
        this.progressRatio(1);
42
        this.shortText(error.message);
43
        return;
44
      }
45
 
46
      this.className('pe-loading-unmanaged');
47
      this.shortText('PE headers');
48
      this.progressRatio(LoadFile._loadWorkPart);
49
      
50
      //TODO: read PE headers, then read Assembly
51
    }
52
 
53
 
54
  }
55
 
56
}